package map;


import collection.set.Teacher;

import java.util.Map;
import java.util.TreeMap;

/**
 * TreeMap特点
 */
public class TreeMapTest {
    public static void main(String[] args) {
        Map<Teacher, String> map = new TreeMap<>((o1, o2) -> Double.compare(o2.getSalary(),o1.getSalary()));
        map.put(new Teacher("tom", 18, 3000), "136期");
        map.put(new Teacher("lsi", 20, 5000), "137期");
        map.put(new Teacher("jack", 34, 7000), "138期");
        map.put(new Teacher("tom", 15, 5000), "139期");
        map.put(new Teacher("tom", 15, 4000), "150期");
        map.forEach((k, v) -> System.out.println(k + "=" + v));

        //Teacher{name='jack', age=34, salary=7000.0}=138期
        //Teacher{name='lsi', age=20, salary=5000.0}=139期
        //Teacher{name='tom', age=15, salary=4000.0}=150期
        //Teacher{name='tom', age=18, salary=3000.0}=136期
        //比较工资，后面的会把前面的值覆盖，但是键不会改变
    }
}
